﻿using Abp;
using Abp.BackgroundJobs;
using Abp.Dependency;
using Abp.Domain.Uow;
using Abp.Threading;
using DHJ.Cost.Notifications;
using DHJ.Cost.Timing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DHJ.Cost.InitData
{
    public class BatchManHourJob : BackgroundJob<UserIdentifier>, ITransientDependency
    {
        private readonly IInitDataAppService _initDataAppService;

        private readonly IAppNotifier _appNotifier;

        public BatchManHourJob(IInitDataAppService initDataAppService, IAppNotifier appNotifier)
        {
            _initDataAppService = initDataAppService;
            _appNotifier = appNotifier;
        }

        [UnitOfWork]
        public override void Execute(UserIdentifier args)
        {
            AsyncHelper.RunSync(() => _initDataAppService.SyncManHours());

            AsyncHelper.RunSync(() => _appNotifier.SendMessageAsync(args, "同步 工时成功"));
        }
    }
}
